# 使用 python -m build 编译
# 然后使用 twine upload dist/* 上传到pypi
import re
from pathlib import Path

from setuptools import setup, find_packages

def get_version():
    """
    从version.py中加载版本号
    """
    version_file = Path('YkPywebview/version.py')
    if version_file.exists():
        with open(version_file, 'r') as f:
            content = f.read()
            # 提取当前版本号
            match = re.search(r'__version__ = "(\d+)\.(\d+)\.(\d+)"', content)
            if match:
                old_year, old_month, last_num = match.groups()
                return f"{old_year}.{old_month}.{last_num}"
    print(f"读取版本号失败")
    return None



with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setup(
    name="YkPywebview",
    version=get_version(),
    author="Yang Ke",
    author_email="540673597@qq.com",
    description="A wrapper library for pywebview with enhanced features",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://gitee.com/yangke02/yk-pywebview",
    packages=['YkPywebview'],
    package_dir={'YkPywebview': 'YkPywebview'},
    install_requires=[
        "pywebview>=3.0"
    ],
    license="MIT",
    classifiers=[
        "Programming Language :: Python :: 3",
        "Operating System :: OS Independent",
    ],
    python_requires=">=3.10",
)
